AddCSLuaFile()

DEFINE_BASECLASS( "class_default" )

local PLAYER = {}

PLAYER.DisplayName			= "Man at Arms"

PLAYER.DefaultWalkSpeed = 180
PLAYER.WalkSpeed = 180
PLAYER.MaxHealth			= 250
PLAYER.StartHealth			= 250

PLAYER.AttackSpeed = 1.75
PLAYER.WeaponDamageMin = 7
PLAYER.WeaponDamageMax = 10

PLAYER.MainhandModel = "models/devin/rpgdm_weapons/basic/bm_sword1.mdl"
PLAYER.OffhandModel = ""
PLAYER.MainHand = nil
PLAYER.OffHand = nil

PLAYER.MAAStance = "melee2"

PLAYER.Spells = {
	51312,
	50,
	60,
	20,
	80121,
	1100,
	1101
}

PLAYER.Gear = {}

function PLAYER:SetupDataTables()

	BaseClass.SetupDataTables( self )

end

function PLAYER:Spawn()
	print(self.HoldType)
	self.Player:StripWeapons()
	self.Player.Parry = 0.1
	self.Player.Dodge = 0.1
	self.Player.Block = 0.0
	if(self.Player:Team() == TEAM_GREEN)then
		self.Gear = 
		{
			1,
			2,
			3
		}
	else
		self.Gear = 
		{
			4,
			5,
			6
		}
	end
	local col = team.GetColor(self.Player:Team())
	self.Player:SetPlayerColor( Vector(	col.r/255, col.g/255, col.b/255 ) )
	self.Player:SetWeaponColor( Vector( col.r/255, col.g/255, col.b/255 ) )
	self.Player:SetWalkSpeed(self.WalkSpeed)
	self:Loadout()
	net.Start("SendSelfMaxHealth")
	net.WriteFloat(self.MaxHealth)
	net.Send(self.Player)
end

function PLAYER:Loadout()
	self.Player.tempEquippedItems = self.Gear
	SetEquipped(self.Player, self.Gear)
	if(self.Player.MainHand != nil and self.Player.MainHand:IsValid())then
		self.Player.MainHand:Remove()
		self.Player.MainHand = nil
	end
	if(self.Player.OffHand != nil and self.Player.OffHand:IsValid())then
		self.Player.OffHand:Remove()
		self.Player.OffHand = nil
	end
	self.Player.MainHand = ents.Create("prop_dynamic")
	self.Player.MainHand:SetModel(self.MainhandModel)
	self.Player.MainHand:PhysicsInit(SOLID_VPHYSICS)
	self.Player.MainHand:SetMoveType(MOVETYPE_NONE)
	self.Player.MainHand:SetSolid( SOLID_VPHYSICS )
	self.Player.MainHand:SetParent(self.Player)
	self.Player.MainHand:AddEffects( EF_BONEMERGE )
	self.Player.MainHand:SetCollisionGroup( COLLISION_GROUP_NONE )
	self.Player:SetNWEntity("MainWep", self.MainHand)
	self.Player.OffHand = ents.Create("prop_dynamic")
	self.Player.OffHand:SetModel(self.OffhandModel)
	self.Player.OffHand:PhysicsInit(SOLID_VPHYSICS)
	self.Player.OffHand:SetMoveType(MOVETYPE_NONE)
	self.Player.OffHand:SetSolid( SOLID_VPHYSICS )
	self.Player.OffHand:SetParent(self.Player)
	self.Player.OffHand:AddEffects( EF_BONEMERGE )
	self.Player.OffHand:SetCollisionGroup( COLLISION_GROUP_NONE )
	self.Player:SetNWEntity("OffWep", self.OffHand)
	self.Player:Give( "weapon_all" )
	self.Player:SetNWString("HoldType", "melee2") 
	local weapon = self.Player:GetWeapon("weapon_all")
		
	weapon.AttackSpeed = self.AttackSpeed
	weapon.MinWeaponDamage = self.WeaponDamageMin
	weapon.MaxWeaponDamage = self.WeaponDamageMax
end

function PLAYER:OnHit(target)
	target:EmitSound("devin/blackbetty/weapons/2HMaceHitPlateCrit.wav", 150, 100+math.random(-10,-30))
	target:SetVelocity((((self.Player:GetPos()) - target:GetPos())*-2))
	ParticleEffect( "blood_erupt", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*7), Angle(0,0,0), target )
end

player_manager.RegisterClass( "class_maa", PLAYER, "class_default" )